Skip to content

Refactor src into focused modules; reduce dead/redundant code#7

Draft
Copilot wants to merge 3 commits intomasterfrom
copilot/refactor-code-into-modules
Draft

Refactor src into focused modules; reduce dead/redundant code#7
Copilot wants to merge 3 commits intomasterfrom
copilot/refactor-code-into-modules

Conversation

Copy link

Copilot AI commented Feb 23, 2026

Splits large flat files into focused modules and removes dead/commented code throughout. Net result: ~87 lines removed, improved encapsulation.

Module reorganisation

  • src/nwb.rssrc/nwb/ with data.rs (types) and loader.rs (SQL loading logic)
  • src/world.rssrc/world/ with resources.rs (Bevy resources/components) and systems.rs (systems)
  • src/lib.rs inline I/O helpers → src/io.rs

Sub-modules are private; only the minimal public API is re-exported:

// nwb/mod.rs
mod data;
mod loader;
pub use data::NWBNetworkData;
pub use loader::preprocess_roadmap;

// world/mod.rs — LoadedMaterials/WorldTracker are internal; removed from pub exports
mod resources;
mod systems;
pub use resources::{WorldConfig, WorldEntity, WorldEntitySelectionType};
pub use systems::convert;

Dead code removed

  • FilterResource {} — unused struct
  • Commented-out Camera3d spawn block, old config paths, unused plugins in main.rs
  • Commented-out process_edges(0, …) call in ui/layers.rs
  • Dead feature flags (iter_collect_into, map_try_insert, test) in main.rs binary entry point

Simplifications

spatial.rsread_f64/read_u32 each repeated 4–8 identical iter.next().ok_or(…)? expressions; replaced with a shared const-generic helper:

fn read_bytes<'a, I, const N: usize>(iter: &mut I) -> rusqlite::types::FromSqlResult<[u8; N]>
where I: Iterator<Item = &'a u8> {
    let mut bytes = [0u8; N];
    for b in &mut bytes {
        *b = *iter.next().ok_or(rusqlite::types::FromSqlError::InvalidType)?;
    }
    Ok(bytes)
}

stopwatch! macro — reduced from 4 arms to 1: the $x:block arm was unreachable (shadowed by $x:expr), and the two print variants were never called.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: BlockCat <1307268+BlockCat@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor code into nice modules Refactor src into focused modules Feb 23, 2026
Copilot AI requested a review from BlockCat February 23, 2026 09:03
…isibility

Co-authored-by: BlockCat <1307268+BlockCat@users.noreply.github.com>
Copilot AI changed the title Refactor src into focused modules Refactor src into focused modules; reduce dead/redundant code Feb 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants